﻿@page
@{ Layout = "_Layout"; }

<div style="height: 10px"></div>

<el-form ref="template" :model="template" :inline="true" size="small" :rules="rules">
  <el-form-item label="模板名称" prop="templateName">
    <el-input v-model="template.templateName" placeholder="请输入模板名称"></el-input>
  </el-form-item>
  <el-form-item label="模板文件" prop="relatedFileName">
    <el-input v-model="template.relatedFileName" placeholder="请输入模板文件"></el-input>
    <div class="tips">路径以/分隔，文件名以T_开头</div>
  </el-form-item>
  <el-form-item label="生成文件名" v-if="isCreatedFileFullName()" prop="createdFileFullName">
    <el-input v-model="template.createdFileFullName" placeholder="请输入生成文件名"></el-input>
    <div class="tips" v-html="createdFileFullNameTips"></div>
  </el-form-item>
  
  <el-form-item label="文件扩展名">
    <el-select v-model="template.createdFileExtName" placeholder="请选择文件扩展名">
      <el-option v-for="createdFileExtName in createdFileExtNames" :key="createdFileExtName" :label="createdFileExtName" :value="createdFileExtName"></el-option>
    </el-select>
    <div class="tips">文件扩展名将决定生成文件的扩展名</div>
  </el-form-item>
</el-form>

<el-row>
  <el-col :span="24">
    <el-button v-if="templateId" type="text" icon="fa fa-magic" v-on:click="btnCreateClick"> 生成页面</el-button>
    <el-button v-if="templateId" type="text" icon="el-icon-files" v-on:click="btnRestoreClick">还原历史版本</el-button>
    <el-button type="text" icon="el-icon-brush" v-on:click="btnFormatClick">格式化代码</el-button>
  </el-col>
</el-row>

<div id="templateContent" style="width:99%; height: 550px; border: 1px solid #d7dae2;"></div>

<div style="margin: 15px 0; text-align: center">
  <el-button type="primary" size="small" v-on:click="btnSubmitClick(false)">保 存</el-button>
  <el-button type="success" size="small" v-on:click="btnSubmitClick(true)">保存并关闭</el-button>
</div>

@section Scripts{
  <script src="/sitefiles/assets/lib/monaco-editor/min/vs/loader.js"></script>
  <script src="/sitefiles/assets/js/admin/cms/templatesEditor.js" type="text/javascript"></script>
}
